from rest_framework import serializers
from .models import Gathering


class GatheringListSerializer(serializers.ModelSerializer):


    class Meta:
        model = Gathering
        fields = ['id','name','image','city','starttime','endrolltime','users']


class GatheringSerializer(serializers.ModelSerializer):
    class Meta:
        model = Gathering
        fields = "__all__"

    # def create(self, validated_data):
    #
    #     # 1、新建分组
    #     gathering = Gathering.objects.create(**validated_data)
    #     # 2、新建分组权限中间表数据
    #     #gathering.permissions.set(users) # 根据参数指定的多个权限，以"覆盖"的方式插入中间表数据
    #     gathering.permissions.add(*users) # 插入多个中间表数据，不会删除已有的数据
    #
    #     return gathering
